<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>用户授权</title>
</head>
<link type="text/css" rel="stylesheet" th:href="@{~/bootstrap-3.3.7/css/bootstrap.css}"/>
<script type="text/javascript" th:src="@{~/bootstrap-3.3.7/js/jquery.js}"></script>
<script type="text/javascript" th:src="@{~/bootstrap-3.3.7/js/bootstrap.js}"></script>

<body>

<div th:align="center">
    <h3 th:text="${user.name}+授权页面"></h3>
</div>
<span th:each="r,stat : ${roles}">
        <input type="checkbox" th:value="${r.id}" th:name="id" th:text="${r.description}"
               th:checked="${r.flag}"/>
    </div>
</span>
<script>

    function xiugai(uid) {
        var ids = "";
        $("[name='id']:checked").map(function () {
            ids += " ," + $(this).val();
        });
        ids = ids.substring(2);

        if(ids == ""){
            ids = 0;
        }

        $.post(
            "/user/shouquanUser",
            {
                ids: ids,
                uid: uid
            },
            function (data) {
                if (data == 1) {
                    alert("成功");
                    location.href = "/user/listUser";
                } else {
                    alert("失败")
                }
            },
            "json"
        );

    }

</script>

<a href="javascript:void(0)"  th:onclick="'javascript:xiugai(\''+${user.id}+'\')'" class="btn btn-success btn-primary btn-xs">修改权限</a>

</body>
</html>